// 图像形状.............................................................................................................................................................................
function ImageShape(imageSource, x, y, width, height){
	var self = this;

	this.image = new Image();
	this.imageLoaded = false;
	this.points = [new Point(x, y)];
	this.x = x;
	this.y = y;

	this.image.src= imageSource;
	this.image.addEventListener('load', function(e){
		self.setPolygonPoints();
		self.imageLoaded = true;
	}, false);
}

ImageShape.prototype = new Polygon();

ImageShape.prototype.fill = function(context){
	// Nothing to do.
};

ImageShape.prototype.setPolygonPoints = function(){
	this.points.push(new Point(this.x + this.image.width, this.y));
	this.points.push(new Point(this.x + this.image.width, this.y + this.image.height));
	this.points.push(new Point(this.x, this.y + this.image.height));
};

ImageShape.prototype.drawImage = function(context){
	context.drawImage(this.image, this.points[0].x, this.points[0].y);
};

ImageShape.prototype.stroke = function(context){
	var self = this;

	if(this.imageLoaded){
		this.drawImage(context);
	}else{
		this.image.addEventListener('load', function(e){
			self.drawImage(context);
		}, false);
	}
};